
cdef extern from "cxtypes.h":

    ctypedef void CvArr
    
    #-------- Image Type IplImage -----------#
        
    struct _IplImage:
        int nSize
        int ID
        int nChannels
        int depth
        int dataOrder
        int origin
        int width
        int height
        int imageSize        
        int widthStep
        char* imageData
        char* imageDataOrigin        
    ctypedef _IplImage IplImage
    
    struct _IplROI:
        int coi
        int xOffset
        int yOffset
        int width
        int height 
    ctypedef _IplROI IplROI
    
    struct _IplConvKernel:
        int nCols
        int nRows
        int anchorX
        int anchorY
        int* values
        int nShiftR
    ctypedef _IplConvKernel IplConvKernel
    
    struct _IplConvKernelFP:
        int nCols
        int nRows
        int anchorX
        int anchorY
        float* values        
    ctypedef _IplConvKernelFP IplConvKernelFP
    
    #--------- Matrix Type CvMat -----------#    
    
    ctypedef union CvMat_uProxy:
        unsigned char* ptr
        short* s
        int* i
        float* fl
        double* db
        
    ctypedef struct CvMat:
        int type
        int step
        CvMat_uProxy data
        int rows
        int cols
        
    #-------- ND Matrix CvMatND ------------#
    ctypedef union CvMatND_uProxy:
        unsigned char* ptr
        float* fl
        double* db
        int* i
        short* s
    
    ctypedef struct dimProxy:
        int size
        int step
            
    ctypedef struct CvMatND:
        int type
        int dims
        CvMatND_uProxy data
        dimProxy dim
        
                 
        
    #-------- Histogram --------------------#
    
    ctypedef struct CvHistogram:
        int type
        CvArr* bins
        float thresh[32][2]
        float** thresh2
        CvMatND mat
        
    #-------- Other Supplementary Types -------#    
    ctypedef struct CvSize:
        int width
        int height
    
    CvSize cvSize(int width, int height) nogil
    
    ctypedef struct CvPoint:
        int x
        int y
        
    CvPoint cvPoint(int x, int y) nogil
    
    ctypedef struct CvScalar:
        double val[4]
        
    CvScalar cvScalar(double val0, double val1, double val2, double val3) nogil
    CvScalar cvRealScalar(double val0) nogil
    CvScalar cvScalarAll(double val0123) nogil
    
    
    
cdef extern from "cxcore.h":
    
    IplImage* cvCreateImage(CvSize size, int depth, int channels) nogil
    
    void cvReleaseImage(IplImage** image) nogil
    
    IplImage* cvCloneImage(IplImage* image) nogil

    CvMat* cvCreateMat(int rows, int cols, int type) nogil
    
    void cvReleaseMat(CvMat** mat) nogil
    
    CvMat* cvCloneMat(CvMat* mat) nogil
    
    CvMatND* cvCreateMatND(int dims, int* sizes, int type) nogil
       
    void cvReleaseMatND(CvMatND** mat) nogil
    
    CvMatND* cvCloneMatND(CvMatND* mat) nogil
    
    
    
    
